home *** CD-ROM | disk | FTP | other *** search
/ Chip: 2005 Utilities / CHIP Utilities 2005.7z / CHIP Utilities 2005.iso / docs / maxblast / www.maxtor.com / maxtor / en_us / scripts / main.js < prev    next >
Text File  |  2004-07-09  |  14KB  |  697 lines

  1. use( "thing.screen" );
  2.  
  3.  
  4.  
  5. function setTabOn(tabID){
  6.  
  7.     if(document.all && document.getElementById(tabID) ) document.getElementById(tabID).className = "tabOn";
  8.  
  9.     }
  10.  
  11.  
  12.  
  13. function winPop(url,width,height) {
  14.  
  15.         // Use to pop a new window with no browser buttons
  16.  
  17.         if (url != null) {
  18.  
  19.                 if (width == null) width = 640;
  20.  
  21.                 if (height == null) height = 480;
  22.  
  23.                 var atts = "width=" + (width + 15) + ",height=" + (height + 15) + ",resizable,scrollbar,scrollbars";
  24.  
  25.                 var newwin = window.open(url, "newwin", atts);
  26.  
  27.                 newwin.focus();
  28.  
  29.                 }
  30.  
  31.         }
  32.  
  33.  
  34.  
  35. function openNewWindow(URLtoOpen, windowName, windowFeatures) { 
  36.  
  37.         // use to pop a new window with user specified settings
  38.  
  39.         if (URLtoOpen != null) {
  40.  
  41.             if (windowName == null) windowName = "newWindow";
  42.  
  43.             if (windowFeatures == null) windowFeatures = "width=640,height=480,resizable";
  44.  
  45.             var newWindow = window.open(URLtoOpen, windowName, windowFeatures); 
  46.  
  47.             }
  48.  
  49.         }
  50.  
  51.  
  52.  
  53. function clicker(url) {
  54.  
  55.     // Shareholder.com function used for popping Annual Report
  56.  
  57.     if (navigator.userAgent.indexOf("MSIE") == -1) {
  58.  
  59.         var newwindow = window.open(url, 'Report', 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=yes,width=1025,height=700,top=1,left=1');  
  60.  
  61.         newwindow.focus();
  62.  
  63.         }
  64.  
  65.     else {
  66.  
  67.         window.open(url, 'Report', 'toolbar=no,width=1006,height=775,directories=no,status=yes,scrollbars=yes,resizable=yes,menubar=no,top=1,left=1');
  68.  
  69.         }
  70.  
  71.     }
  72.  
  73.  
  74.  
  75. /*
  76.  
  77. *************************************************************************
  78.  
  79. Use this function below to validate form input.
  80.  
  81. The form tag should use an onSubmit:
  82.  
  83.  
  84.  
  85. <form action="" method="post" onSubmit="validate(this.form)">
  86.  
  87.  
  88.  
  89. Then in the tags you need an additional VALIDATOR parameter:
  90.  
  91.  
  92.  
  93. <input type="" name="" VALIDATOR="notEmptyPat">
  94.  
  95.  
  96.  
  97. It MUST be uppercase and call one of the patterns below.
  98.  
  99. It helps the user if your input NAME is descriptive enough to 
  100.  
  101. let them know which field needs input.
  102.  
  103.  
  104.  
  105. Monica Israels
  106.  
  107. 9/16/02
  108.  
  109. */
  110.  
  111.  
  112.  
  113. function validate(objForm) {
  114.  
  115.     var PatternsDict = new Object();
  116.  
  117.     PatternsDict.zipPat = /\d{5}(-\d{4})?/;  // matches zip codes
  118.  
  119.     PatternsDict.emailPat = /.*@.*\..*/;  // matches email addresses
  120.  
  121.     PatternsDict.notEmptyPat = /.{1,}/;  // matches at least one character
  122.  
  123.     PatternsDict.numberPat = /\d/;  // matches numbers only
  124.  
  125.     PatternsDict.pwPat = /^\D{1}\S{3,9}$/;  // matches between 4 and 10 characters with non-digit leading
  126.  
  127.     PatternsDict.currencyPat = /\$\d{1,3}(,\d{3})*\.\d{2}/;  // matches currency with commas
  128.  
  129.     PatternsDict.timePat = /^([1-9]|1[0-2]):[0-5]\d$/;  // matches times
  130.  
  131.  
  132.  
  133.     var elArr = objForm.elements;
  134.  
  135.     for(var i=0; i<elArr.length; i++)
  136.  
  137.     with(elArr[i]) { 
  138.  
  139.         var v = elArr[i].VALIDATOR; 
  140.  
  141.         if(!v) continue; 
  142.  
  143.         
  144.  
  145.         var thePat = PatternsDict[v]; 
  146.  
  147.         var gotIt = thePat.exec(value); 
  148.  
  149.         if(!gotIt) {
  150.  
  151.             var returnStr;
  152.  
  153.             returnStr = "The " + name + " field is invalid, this field is required in order to submit this form.  Please try again!";
  154.  
  155.             alert(returnStr);
  156.  
  157.             return false;
  158.  
  159.             }
  160.  
  161.         } 
  162.  
  163.     return true;
  164.  
  165.     }
  166.  
  167.  
  168.  
  169. /*
  170.  
  171. ***************************************************
  172.  
  173. This function MUST BE USED IN ADDITION to the flash_detection.js script!!!
  174.  
  175.  
  176.  
  177. First call flash_detection.js
  178.  
  179. Then start a new script block
  180.  
  181. This detects Macromedia flash versions and returns true or false based on the version tested.
  182.  
  183. The default version is 4.
  184.  
  185. Usage:
  186.  
  187.     detectFlash(4);
  188.  
  189. This will return true or false to check for version 4.  Use the result accordingly:
  190.  
  191.     if (detectFlash(4)) { ... }
  192.  
  193.     else { ... }
  194.  
  195.  
  196.  
  197. Monica Israels
  198.  
  199. 9/18/02
  200.  
  201. */
  202.  
  203. function detectFlash(requiredVersion) {
  204.  
  205.     if (requiredVersion == null) requiredVersion = 4; 
  206.  
  207.     
  208.  
  209.     if (navigator.plugins) {
  210.  
  211.         if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
  212.  
  213.             var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
  214.  
  215.             var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
  216.  
  217.             var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
  218.  
  219.             flash2Installed = flashVersion == 2;
  220.  
  221.             flash3Installed = flashVersion == 3;
  222.  
  223.             flash4Installed = flashVersion == 4;
  224.  
  225.             flash5Installed = flashVersion == 5;
  226.  
  227.             flash6Installed = flashVersion == 6;
  228.  
  229.             }
  230.  
  231.         }
  232.  
  233.  
  234.  
  235.     for (var i = 2; i <= maxVersion; i++) {
  236.  
  237.         if (eval("flash" + i + "Installed") == true) actualVersion = i;
  238.  
  239.         }
  240.  
  241.  
  242.  
  243.     if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 2;
  244.  
  245.  
  246.  
  247.     if (actualVersion >= requiredVersion) {
  248.  
  249.         hasRightVersion = true;
  250.  
  251.         return true;
  252.  
  253.         }
  254.  
  255.         
  256.  
  257.     else {
  258.  
  259.         return false;
  260.  
  261.         }
  262.  
  263.     }
  264.  
  265.  
  266.  
  267. /*******************************************************************
  268.  
  269. HANDLER FOR DROP-DOWN MENUS
  270.  
  271.  
  272.  
  273. For drop-downs this checks to make sure there is a valid selection
  274.  
  275. before proceeding.
  276.  
  277.  
  278.  
  279. Monica Israels
  280.  
  281. 2/20/03
  282.  
  283. */
  284.  
  285. function checkEmptySelect(value) {   
  286.  
  287.     if (value == "-") alert("Please select a valid entry from the drop-down menu to continue.");
  288.  
  289.     else window.location = value;
  290.  
  291.     return false;
  292.  
  293.     }
  294.  
  295.  
  296.  
  297.  
  298.  
  299. /*******************************************************************
  300.  
  301. FUNCTIONS FOR WORKING WITH COOKIES
  302.  
  303.  
  304.  
  305. Three functions for reading, writing and deleting cookies using
  306.  
  307. Javascript.
  308.  
  309.  
  310.  
  311. Monica Israels
  312.  
  313. 3/12/03
  314.  
  315. */
  316.  
  317. function getCookie(name) {
  318.  
  319.     var start = document.cookie.indexOf(name + '=');
  320.  
  321.     var len = start + name.length + 1;
  322.  
  323.     if ((!start) && (name != document.cookie.substring(0,name.length)))
  324.  
  325.         return null;
  326.  
  327.     if (start == -1)
  328.  
  329.         return null;
  330.  
  331.     var end = document.cookie.indexOf(';', len);
  332.  
  333.     if (end == -1) 
  334.  
  335.         end = document.cookie.length;
  336.  
  337.     return unescape(document.cookie.substring(len, end));
  338.  
  339.     }
  340.  
  341.  
  342.  
  343. function setCookie(name,value,expires,path,domain,secure) {
  344.  
  345.     document.cookie = name + '=' + escape(value) + 
  346.  
  347.     ((expires) ? ';expires=' + expires.toGMTString() : '') +
  348.  
  349.     ((path) ? ';path=' + path : '') + 
  350.  
  351.     ((domain) ? ';domain=' + domain : '') +
  352.  
  353.     ((secure) ? ';secure' : '');
  354.  
  355.     }
  356.  
  357.  
  358.  
  359. function deleteCookie(name,path,domain) {
  360.  
  361.     if (getCookie(name))
  362.  
  363.         document.cookie = name + '=' +
  364.  
  365.         ((path) ? ';path=' + path : '') +
  366.  
  367.         ((domain) ? ';domain=' + domain : '') +
  368.  
  369.         ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
  370.  
  371.     }
  372.  
  373.  
  374.  
  375.  
  376.  
  377. /*
  378.  
  379. *************************************************************************
  380.  
  381. Use this function below to count the number of serial numbers in a form
  382.  
  383. field.  If more than the maximum have been entered the user gets a
  384.  
  385. confirm box telling them that the remainder will be ignored if they 
  386.  
  387. continue.  Serial numbers must be separated by spaces or new lines.
  388.  
  389.  
  390.  
  391. checkSerialNumber(maximum, objForm)
  392.  
  393.  
  394.  
  395. maximum: the maximum number of serial numbers allowed (integer)
  396.  
  397. objForm: the form name
  398.  
  399.  
  400.  
  401. Ezra Castillo
  402.  
  403. 6/5/03
  404.  
  405. */
  406.  
  407. function countSerialNumbers(maximum, objForm) {
  408.  
  409.     var serial_numbers = objForm.serial_numbers.value;
  410.  
  411.     var regexp = /\s/;
  412.  
  413.     var serialArray = serial_numbers.split(regexp);
  414.  
  415.     var arrayCount = serialArray.length;
  416.  
  417.     
  418.  
  419.     if (arrayCount > maximum) {
  420.  
  421.         if (confirm("You have entered " + arrayCount + " serial numbers which is more than the " + maximum + " allowed. To \ncontinue \'Click OK\' below to process the first " + maximum + " serial numbers, noting the \nremaining will not be processed ignoring the rest.  Click Cancel below to return \nto the form to edit your list of serial numbers.")) 
  422.  
  423.             return true;    
  424.  
  425.         else
  426.  
  427.             return false;
  428.  
  429.         }    
  430.  
  431.     }
  432.  
  433.  
  434.  
  435.  
  436.  
  437. /*
  438.  
  439. *************************************************************************
  440.  
  441. This function pops up alert boxes based on the key passed to the function.
  442.  
  443.  
  444.  
  445. Ezra Castillo
  446.  
  447. 6/5/03
  448.  
  449. */
  450.  
  451. function alertBoxPop(key) {
  452.  
  453.     // add new definitions here as needed
  454.  
  455.     // please list in alphabetical order
  456.  
  457.     
  458.  
  459.     if (key.toUpperCase() == "ADVANCE_RMA") alert('Help: Advance Replacement \n\nCreate an Advance Return Material Authorization (RMA) for a defective product.  A replacement product will be shipped to you first.  A credit card is required.');
  460.  
  461.     
  462.  
  463.     else if (key.toUpperCase() == "EXPIRATION_DATE") alert('Help: Expiration Date \n\nThe warranty on this hard drive expires at midnight at the beginning of the date listed.');
  464.  
  465.  
  466.  
  467.     else if (key.toUpperCase() == "REPLACEMENT_PROCESS") alert('Help: Replacement Process \n\nFollow Steps 3 through 8.');
  468.  
  469.     
  470.  
  471.     else if (key.toUpperCase() == "STANDARD_RMA") alert('Help: Standard Replacement \n\nCreate a Standard Return Material Authorization (RMA) for a defective product.  The replacement product will be shipped after the defective product has been received.  A credit card is not required.');
  472.  
  473.  
  474.  
  475.     else if (key.toUpperCase() == "TLA") alert('Help: TLA Number \n\nThe Top Level Assembly (TLA) number contains the hard drive\'s \nmodel number. TLA numbers are used in our warranty database \nto help identify a hard drvies\'s product family and capacity point. \nThe TLA number can be found on the label located on the top of \nthe hard drive. The TLA number may also be referred to as the \n\"material number\" by our customer service department.');    
  476.  
  477.  
  478.  
  479.     else if (key.toUpperCase() == "CHECK_STATUS") alert('Help: Status \n\nThis column will display the current processing status of your \nRMA. RMA status can be obtained for all RMA\'s created on our web \nsite or through our Customer Support Center. You will also be notified by e-mail \nwhen your replacement drive has been shipped from Maxtor.');
  480.  
  481.  
  482.  
  483.     else if (key.toUpperCase() == "CHECK_MESSAGE") alert('Help: Tracking Number \n\nIf your replacement drive has been shipped from Maxtor, the shipper\'s \ntracking number will be displayed in this column. If a tracking \nnumber is displayed, please click on it to obtain current shipping status.');
  484.  
  485.     
  486.  
  487.     }
  488.  
  489.  
  490.  
  491.  
  492.  
  493. /*
  494.  
  495. ************************************************************************
  496.  
  497. Confirm pop-up box for RMA back button
  498.  
  499. Ezra Castillo
  500.  
  501. 6/30/03
  502.  
  503. */
  504.  
  505. function checkDriveConfirm(){
  506.  
  507.     if (confirm("Click OK below to return to the main page of this application \nto add another serial number. Note that the current Warranty \nStatus Results will be lost. Click Cancel below to remain on \nthis page.")) 
  508.  
  509.         return true;    
  510.  
  511.     else
  512.  
  513.         return false;
  514.  
  515.     }
  516.  
  517.  
  518.  
  519.     
  520.  
  521. /*
  522.  
  523. *************************************************************************
  524.  
  525. This function pops up a confirm box for the High Volume Warranty Lookup
  526.  
  527. application when the user clicks a link to start the process over.  If OK 
  528.  
  529. is pressed they are sent to the beginning of the application.  Otherwise no 
  530.  
  531. action is taken.
  532.  
  533.  
  534.  
  535. Ezra Castillo
  536.  
  537. 6/5/03
  538.  
  539. */
  540.  
  541. function hvwlStartOver() {
  542.  
  543.     if (confirm("Click OK below to return to the main page of this application to \nadd more serial numbers.  Note that the current Warranty Status \nResults will be lost. \n\nClick Cancel below to remain on this page.")) 
  544.  
  545.         window.location.href = "index.cfm";
  546.  
  547.     }
  548.  
  549.     
  550.  
  551. /*
  552.  
  553. Ezra Castillo
  554.  
  555. 7/20/2003
  556.  
  557. */
  558.  
  559. function createRMAConfirm(){
  560.  
  561.     var value = document.shippack.ship_and_pack.checked;
  562.  
  563.  
  564.  
  565.     if (value == false){
  566.  
  567.         if (confirm("You must agree to follow these Procedures to continue this RMA \nprocess. Click OK below to return to this page to check the checkbox \nstating you agree to the Procedure detailed here. Click Cancel \nbelow to end this RMA process (your information will not be saved).")) 
  568.  
  569.             return false;
  570.  
  571.     }
  572.  
  573. }
  574.  
  575. /*
  576.  
  577. Ezra Castillo
  578.  
  579. 7/24/2003
  580.  
  581. */
  582.  
  583. function purchaseLoc(){
  584.  
  585.     var country = document.troubleshoot.shipping_country.value;
  586.  
  587.     
  588.  
  589.     window.location.href = "03_troubleshooting.cfm?country="+country;
  590.  
  591. }
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599. /* 
  600.  
  601. Ezra Castillo
  602.  
  603. 12/11/03
  604.  
  605. */
  606.  
  607. function createRMAConfirm2(submitTypImage) {
  608.  
  609.    submitTypImage.disabled = true;
  610.  
  611.    var objForm = document.shippack;
  612.  
  613.    
  614.  
  615.    if (objForm.ship_and_pack.checked == false){
  616.  
  617.     submitTypImage.disabled = false;
  618.  
  619.     if (confirm("You must agree to follow these Procedures to continue this RMA \nprocess. Click OK below to return to this page to check the checkbox \nstating you agree to the Procedure detailed here. Click Cancel \nbelow to end this RMA process (your information will not be saved).")) 
  620.  
  621.      return false;
  622.  
  623.    } 
  624.  
  625.    
  626.  
  627.    submitTypImage.form.method = 'post';
  628.  
  629.    submitTypImage.form.action = '07_ship_and_pack.cfm';
  630.  
  631.    submitTypImage.form.submit();
  632.  
  633.  
  634.  
  635.   }
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643. /*
  644.  
  645. *************************************************************************
  646.  
  647. The following functions are used in the world map polygon rollovers to preload
  648.  
  649. and swapout images for the onMouseover function. To keep the swapping simplified, 
  650.  
  651. each rollover is an entire world map and not simple geometric slice images because
  652.  
  653. the polygons are the shape of the continents and multiple slice rollovers would 
  654.  
  655. otherwise be required.
  656.  
  657.  
  658.  
  659. Steven Reiser
  660.  
  661. 7/31/03
  662.  
  663. */
  664.  
  665.  
  666.  
  667. function findObj(n, d) { 
  668.  
  669.   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  670.  
  671.     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  672.  
  673.   if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  674.  
  675.   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  676.  
  677.   if(!x && d.getElementById) x=d.getElementById(n); return x;
  678.  
  679. }
  680.  
  681. function swapImage() { 
  682.  
  683.   var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
  684.  
  685.    if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
  686.  
  687. }
  688.  
  689. function preloadImages() { 
  690.  
  691.  var d=document; if(d.images){ if(!d.p) d.p=new Array();
  692.  
  693.    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
  694.  
  695.    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
  696.  
  697. }